In Google Sheet, I have already list out all the filtered files as needed throughout the parent folder and child folder. I have pushed all the important details into the sheet as well.
My issue now is I am trying to get each childFolderId value from childFolders while and pass it into the fileIter while and then push into a list of array to be displayed in Google Sheet.
Here is the codes:
var parent = DriveApp.getFolderById(folderId);
getChildFiles(parentName, parent, currentSheet, list, excluded);
The main function is:
function getChildFiles(parentName, parent, sheet) {
var fileIter = parent.searchFiles("title contains 'completed'and title contains 'Verification
Visit Direct Suppliers'and mimeType='application/vnd.openxmlformats-
officedocument.spreadsheetml.sheet'");
var output = [];
var childFolders = parent.getFolders();
while (childFolders.hasNext()) {
var childFolder = childFolders.next();
var childFolderName = childFolder.getName();
getChildFiles(
parentName + ' |--> ' + childFolderName, childFolder,sheet
);
}
while (fileIter.hasNext()) {
var file = fileIter.next();
var fileName = file.getName();
var fileID = file.getId();
var path = parentName + ' |--> ' + fileName;
output.push([fileID, fileName, path]);
}
if (output.length) {
var last_row = sheet.getLastRow();
sheet.getRange(last_row + 1, 1, output.length, 3).setValues(output);
SpreadsheetApp.flush();
}
}
I am trying to get the childFolderId without messing up the filtering code. This is because if i insert the fileIter while inside the childFolders while, None of the files is listed in the google sheet.
But if i split both while i manage to list all the files i need except the childFolderId
How can I get the value of childFolderId and push it into the sheet?